package com.shop.shoppingmall.controller;

import com.shop.shoppingmall.entity.TSpec;
import com.shop.shoppingmall.service.TSpecService;
import com.shop.shoppingmall.util.api.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (TSpec)表控制层
 *
 * @author makejava
 * @since 2020-09-23 16:16:54
 */
@RestController
@RequestMapping("tSpec")
public class TSpecController {
    /**
     * 服务对象
     */
    @Resource
    private TSpecService tSpecService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TSpec selectOne(Integer id) {
        return this.tSpecService.queryById(id);
    }

    /**
     * 添加商品的属性规格
     * @param map
     * @return
     */
    @PostMapping("/addTsSpect")
    public Result addTsSpect(@RequestBody Map map){
        Integer id = (Integer) map.get("id");
        String specName = (String) map.get("specName");
        Integer isParent = (Integer) map.get("isParent");
        return tSpecService.addTsSpect(id,specName,isParent);
    }

    @GetMapping("/selectAll")
    public Result selectAll(){
        return tSpecService.selectAll();
    }

}